package com.qst.crop.service.impl;

import com.qst.crop.dao.FinancingIntentionDao;
import com.qst.crop.entity.FinancingIntention;
import com.qst.crop.service.FinancingIntentionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

@Service
public class FinancingIntentionServiceImpl implements FinancingIntentionService {

    @Autowired
    private FinancingIntentionDao financingIntentionDao;

    /**
     * @Description : 查询融资意向
     *  * @param
     * @Return : com.qst.crop.common.Result<java.util.List<com.qst.crop.entity.FinancingIntention>>
     */
    @Override
    public List<FinancingIntention> selectIntentionByName(String username) {
        return financingIntentionDao.selectByName(username);
    }

    /**
     * @Description : 删除融资意向
     *  * @param
     * @Return : com.qst.crop.common.Result<>
     */
    @Override
    public void deleteIntentionByName(String username) {
        financingIntentionDao.deleteByName(username);
    }

    /**
     * @Description : 添加融资意向
     *  * @param financingIntention
     * @Return : com.qst.crop.common.Result
     */
    @Override
    public void insertIntensionByName(FinancingIntention financingIntention) {
        financingIntention.setCreateTime(LocalDateTime.now());
        financingIntention.setUpdateTime(LocalDateTime.now());
        financingIntentionDao.insertIntension(financingIntention);
    }

    /**
     * @Description : 更新融资意向
     *  * @param financingIntention
     * @Return : com.qst.crop.common.Result
     */
    @Override
    public void updateIntensionByName(FinancingIntention financingIntention) {

        financingIntention.setUpdateTime(LocalDateTime.now());
        financingIntentionDao.updateIntensionByName(financingIntention);
    }
}
